using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace tutors_clus.Models.Mapping
{
    public class commentMap : EntityTypeConfiguration<comment>
    {
        public commentMap()
        {
            // Primary Key
            this.HasKey(t => t.id_com);

            // Properties
            this.Property(t => t.title_com)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("comment");
            this.Property(t => t.id_com).HasColumnName("id_com");
            this.Property(t => t.id_cou).HasColumnName("id_cou");
            this.Property(t => t.id_stu).HasColumnName("id_stu");
            this.Property(t => t.title_com).HasColumnName("title_com");
            this.Property(t => t.content_com).HasColumnName("content_com");
            this.Property(t => t.createdate).HasColumnName("createdate");
            this.Property(t => t.parent).HasColumnName("parent");
            this.Property(t => t.isrepply).HasColumnName("isrepply");

            // Relationships
            this.HasRequired(t => t.course)
                .WithMany(t => t.comments)
                .HasForeignKey(d => d.id_cou);
            this.HasOptional(t => t.student)
                .WithMany(t => t.comments)
                .HasForeignKey(d => d.id_stu);

        }
    }
}
